package org.hongqi.common.senpec.base.mybatisplus;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import org.hongqi.common.senpec.base.sevlet.Result;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.util.Collection;

public interface IBaseService<T> extends IService<T> {
    @Transactional(rollbackFor = Exception.class)
    Result<T> mySave(T entity);

    @Transactional(rollbackFor = Exception.class)
    Result<?> myRemoveById(Long id);

    @Transactional(rollbackFor = Exception.class)
    Result<T> myUpdateById(T entity);

    Result<T> myGetById(Long id);


    default Result<IPage<T>> myListObjsWithPage(T entity) {
        return null;
    }

    @Transactional(rollbackFor = Exception.class)
    default Result<Collection<T>> myListObjsWithoutPage(T entity) {
        return null;
    }

    @Transactional(rollbackFor = Exception.class)
    default Result<Collection<T>> myListTree(T entity) {
        return null;
    }

    default LambdaQueryWrapper<T> createLambdaQueryWrapper(T entity) {
        return null;
    }

    default void myExportObjs(HttpServletResponse response) {
        System.out.println(response);
    }

    @Transactional(rollbackFor = Exception.class)
    default void myImportObjs(Long creator, MultipartFile file) {
        System.out.println(file);
    }

    T myGetObjById(Long id);
}
